###################################################################
#Figure 7a - Q1 Local Polynomial Smoothing
###################################################################

library(foreign)
library(extrafont)
library(readstata13)
loadfonts()
data<-read.dta13("Figure78_Q1dataset.dta")
data2<-read.dta13("Figure7_AppropsCountsQ1.dta")
scale<-data[,1]
smooth<-data[,2]
se<-data[,3]
lb<-data[,4]
ub<-data[,5]
cycle<-data2[,1]
points<-data2[,6]

pdf(file="Figure7a.pdf", family="Bookman")
plot(scale, smooth, xlim=c(2, 32), col="white", ylim=c(-120, 110), xlab=expression(paste("Year of Cycle"~italic('t'))), ylab="First Differences (in Frequency of Appropriations Votes)", xaxt="n", main="Q1: Local Polynomial Smoothing")
box() 

polygon(c(scale, rev(scale)), c(lb, rev(ub)), col="gray72", border=NA)

points(scale, smooth, type="l")
points(cycle, points, pch=20)

axis(1, at=2, "1958", las=2)
axis(1, at=3, " ")
axis(1, at=4, "1962", las=2)
axis(1, at=5, " ")
axis(1, at=6, "1966", las=2)
axis(1, at=7, " ")
axis(1, at=8, "1970", las=2)
axis(1, at=9, " ")
axis(1, at=10, "1974", las=2)
axis(1, at=11, " ")
axis(1, at=12, "1978", las=2)
axis(1, at=13, " ")
axis(1, at=14, "1982", las=2)
axis(1, at=15, " ")
axis(1, at=16, "1986", las=2)
axis(1, at=17, " ")
axis(1, at=18, "1990", las=2)
axis(1, at=19, " ")
axis(1, at=20, "1994", las=2)
axis(1, at=21, " ")
axis(1, at=22, "1998", las=2)
axis(1, at=23, " ")
axis(1, at=24, "2002", las=2)
axis(1, at=25, " ")
axis(1, at=26, "2006", las=2)
axis(1, at=27, " ")
axis(1, at=28, "2010", las=2)
axis(1, at=29, " ")
axis(1, at=30, "2014", las=2)
axis(1, at=31, " ")
axis(1, at=32, "2018", las=2)

dev.off()


###################################################################
#Figure 8a - Q1 SE Plot
###################################################################

library(foreign)
library(extrafont)
library(readstata13)
loadfonts()
data<-read.dta13("Figure78_Q1dataset.dta")
scale<-data[,1]
smooth<-data[,2]
se<-data[,3]
lb<-data[,4]
ub<-data[,5]

pdf(file="Figure8a.pdf", family="Bookman")
plot(scale, se, type="l", xlim=c(2, 32), ylim=c(0, 40), xlab=expression(paste("Year of Cycle"~italic('t'))), ylab="Standard Error", xaxt="n", main="Q1: Standard Errors")
box() 

axis(1, at=2, "1958", las=2)
axis(1, at=3, " ")
axis(1, at=4, "1962", las=2)
axis(1, at=5, " ")
axis(1, at=6, "1966", las=2)
axis(1, at=7, " ")
axis(1, at=8, "1970", las=2)
axis(1, at=9, " ")
axis(1, at=10, "1974", las=2)
axis(1, at=11, " ")
axis(1, at=12, "1978", las=2)
axis(1, at=13, " ")
axis(1, at=14, "1982", las=2)
axis(1, at=15, " ")
axis(1, at=16, "1986", las=2)
axis(1, at=17, " ")
axis(1, at=18, "1990", las=2)
axis(1, at=19, " ")
axis(1, at=20, "1994", las=2)
axis(1, at=21, " ")
axis(1, at=22, "1998", las=2)
axis(1, at=23, " ")
axis(1, at=24, "2002", las=2)
axis(1, at=25, " ")
axis(1, at=26, "2006", las=2)
axis(1, at=27, " ")
axis(1, at=28, "2010", las=2)
axis(1, at=29, " ")
axis(1, at=30, "2014", las=2)
axis(1, at=31, " ")
axis(1, at=32, "2018", las=2)

dev.off()



###################################################################
#Figure 7b - Q2 Local Polynomial Smoothing
###################################################################

library(foreign)
library(extrafont)
library(readstata13)
loadfonts()
data<-read.dta13("Figure78_Q2dataset.dta")
data2<-read.dta13("Figure7_AppropsCountsQ2.dta")
scale<-data[,1]
smooth<-data[,2]
se<-data[,3]
lb<-data[,4]
ub<-data[,5]
cycle<-data2[,1]
points<-data2[,6]

pdf(file="Figure7b.pdf", family="Bookman")
plot(scale, smooth, xlim=c(2, 32), col="white", ylim=c(-200, 170), xlab=expression(paste("Year of Cycle"~italic('t'))), ylab="First Differences (in Frequency of Appropriations Votes)", xaxt="n", main="Q2: Local Polynomial Smoothing")
box() 

polygon(c(scale, rev(scale)), c(lb, rev(ub)), col="gray72", border=NA)

points(scale, smooth, type="l")
points(cycle, points, pch=20)

axis(1, at=2, "1958", las=2)
axis(1, at=3, " ")
axis(1, at=4, "1962", las=2)
axis(1, at=5, " ")
axis(1, at=6, "1966", las=2)
axis(1, at=7, " ")
axis(1, at=8, "1970", las=2)
axis(1, at=9, " ")
axis(1, at=10, "1974", las=2)
axis(1, at=11, " ")
axis(1, at=12, "1978", las=2)
axis(1, at=13, " ")
axis(1, at=14, "1982", las=2)
axis(1, at=15, " ")
axis(1, at=16, "1986", las=2)
axis(1, at=17, " ")
axis(1, at=18, "1990", las=2)
axis(1, at=19, " ")
axis(1, at=20, "1994", las=2)
axis(1, at=21, " ")
axis(1, at=22, "1998", las=2)
axis(1, at=23, " ")
axis(1, at=24, "2002", las=2)
axis(1, at=25, " ")
axis(1, at=26, "2006", las=2)
axis(1, at=27, " ")
axis(1, at=28, "2010", las=2)
axis(1, at=29, " ")
axis(1, at=30, "2014", las=2)
axis(1, at=31, " ")
axis(1, at=32, "2018", las=2)

dev.off()


###################################################################
#Figure 8b - Q2 SE Plot
###################################################################

library(foreign)
library(extrafont)
library(readstata13)
loadfonts()
data<-read.dta13("Figure78_Q2dataset.dta")
scale<-data[,1]
smooth<-data[,2]
se<-data[,3]
lb<-data[,4]
ub<-data[,5]

pdf(file="Figure8b.pdf", family="Bookman")
plot(scale, se, type="l", xlim=c(2, 32), ylim=c(0, 80), xlab=expression(paste("Year of Cycle"~italic('t'))), ylab="Standard Error", xaxt="n", main="Q2: Standard Errors")
box() 

axis(1, at=2, "1958", las=2)
axis(1, at=3, " ")
axis(1, at=4, "1962", las=2)
axis(1, at=5, " ")
axis(1, at=6, "1966", las=2)
axis(1, at=7, " ")
axis(1, at=8, "1970", las=2)
axis(1, at=9, " ")
axis(1, at=10, "1974", las=2)
axis(1, at=11, " ")
axis(1, at=12, "1978", las=2)
axis(1, at=13, " ")
axis(1, at=14, "1982", las=2)
axis(1, at=15, " ")
axis(1, at=16, "1986", las=2)
axis(1, at=17, " ")
axis(1, at=18, "1990", las=2)
axis(1, at=19, " ")
axis(1, at=20, "1994", las=2)
axis(1, at=21, " ")
axis(1, at=22, "1998", las=2)
axis(1, at=23, " ")
axis(1, at=24, "2002", las=2)
axis(1, at=25, " ")
axis(1, at=26, "2006", las=2)
axis(1, at=27, " ")
axis(1, at=28, "2010", las=2)
axis(1, at=29, " ")
axis(1, at=30, "2014", las=2)
axis(1, at=31, " ")
axis(1, at=32, "2018", las=2)

dev.off()


###################################################################
#Figure 7c - Q3 Local Polynomial Smoothing
###################################################################

library(foreign)
library(extrafont)
library(readstata13)
loadfonts()
data<-read.dta13("Figure78_Q3dataset.dta")
data2<-read.dta13("Figure7_AppropsCountsQ3.dta")
scale<-data[,1]
smooth<-data[,2]
se<-data[,3]
lb<-data[,4]
ub<-data[,5]
cycle<-data2[,1]
points<-data2[,6]

pdf(file="Figure7c.pdf", family="Bookman")
plot(scale, smooth, xlim=c(2, 32), col="white", ylim=c(-30, 35), xlab=expression(paste("Year of Cycle"~italic('t'))), ylab="First Differences (in Frequency of Appropriations Votes)", xaxt="n", main="Q3: Local Polynomial Smoothing")
box() 

polygon(c(scale, rev(scale)), c(lb, rev(ub)), col="gray72", border=NA)

points(scale, smooth, type="l")
points(cycle, points, pch=20)

axis(1, at=2, "1958", las=2)
axis(1, at=3, " ")
axis(1, at=4, "1962", las=2)
axis(1, at=5, " ")
axis(1, at=6, "1966", las=2)
axis(1, at=7, " ")
axis(1, at=8, "1970", las=2)
axis(1, at=9, " ")
axis(1, at=10, "1974", las=2)
axis(1, at=11, " ")
axis(1, at=12, "1978", las=2)
axis(1, at=13, " ")
axis(1, at=14, "1982", las=2)
axis(1, at=15, " ")
axis(1, at=16, "1986", las=2)
axis(1, at=17, " ")
axis(1, at=18, "1990", las=2)
axis(1, at=19, " ")
axis(1, at=20, "1994", las=2)
axis(1, at=21, " ")
axis(1, at=22, "1998", las=2)
axis(1, at=23, " ")
axis(1, at=24, "2002", las=2)
axis(1, at=25, " ")
axis(1, at=26, "2006", las=2)
axis(1, at=27, " ")
axis(1, at=28, "2010", las=2)
axis(1, at=29, " ")
axis(1, at=30, "2014", las=2)
axis(1, at=31, " ")
axis(1, at=32, "2018", las=2)

dev.off()


###################################################################
#Figure 8c - Q3 SE Plot
###################################################################

library(foreign)
library(extrafont)
library(readstata13)
loadfonts()
data<-read.dta13("Figure78_Q3dataset.dta")
scale<-data[,1]
smooth<-data[,2]
se<-data[,3]
lb<-data[,4]
ub<-data[,5]

pdf(file="Figure8c.pdf", family="Bookman")
plot(scale, se, type="l", xlim=c(2, 32), ylim=c(0, 17), xlab=expression(paste("Year of Cycle"~italic('t'))), ylab="Standard Error", xaxt="n", main="Q3: Standard Errors")
box() 

axis(1, at=2, "1958", las=2)
axis(1, at=3, " ")
axis(1, at=4, "1962", las=2)
axis(1, at=5, " ")
axis(1, at=6, "1966", las=2)
axis(1, at=7, " ")
axis(1, at=8, "1970", las=2)
axis(1, at=9, " ")
axis(1, at=10, "1974", las=2)
axis(1, at=11, " ")
axis(1, at=12, "1978", las=2)
axis(1, at=13, " ")
axis(1, at=14, "1982", las=2)
axis(1, at=15, " ")
axis(1, at=16, "1986", las=2)
axis(1, at=17, " ")
axis(1, at=18, "1990", las=2)
axis(1, at=19, " ")
axis(1, at=20, "1994", las=2)
axis(1, at=21, " ")
axis(1, at=22, "1998", las=2)
axis(1, at=23, " ")
axis(1, at=24, "2002", las=2)
axis(1, at=25, " ")
axis(1, at=26, "2006", las=2)
axis(1, at=27, " ")
axis(1, at=28, "2010", las=2)
axis(1, at=29, " ")
axis(1, at=30, "2014", las=2)
axis(1, at=31, " ")
axis(1, at=32, "2018", las=2)

dev.off()


###################################################################
#Figure 7d - Q4 Local Polynomial Smoothing
###################################################################

library(foreign)
library(extrafont)
library(readstata13)
loadfonts()
data<-read.dta13("Figure78_Q4dataset.dta")
data2<-read.dta13("Figure7_AppropsCountsQ4.dta")
scale<-data[,1]
smooth<-data[,2]
se<-data[,3]
lb<-data[,4]
ub<-data[,5]
cycle<-data2[,1]
points<-data2[,6]

pdf(file="Figure7d.pdf", family="Bookman")
plot(scale, smooth, xlim=c(2, 32), col="white", ylim=c(-220, 140), xlab=expression(paste("Year of Cycle"~italic('t'))), ylab="First Differences (in Frequency of Appropriations Votes)", xaxt="n", main="Q4: Local Polynomial Smoothing")
box() 

polygon(c(scale, rev(scale)), c(lb, rev(ub)), col="gray72", border=NA)

points(scale, smooth, type="l")
points(cycle, points, pch=20)

axis(1, at=2, "1958", las=2)
axis(1, at=3, " ")
axis(1, at=4, "1962", las=2)
axis(1, at=5, " ")
axis(1, at=6, "1966", las=2)
axis(1, at=7, " ")
axis(1, at=8, "1970", las=2)
axis(1, at=9, " ")
axis(1, at=10, "1974", las=2)
axis(1, at=11, " ")
axis(1, at=12, "1978", las=2)
axis(1, at=13, " ")
axis(1, at=14, "1982", las=2)
axis(1, at=15, " ")
axis(1, at=16, "1986", las=2)
axis(1, at=17, " ")
axis(1, at=18, "1990", las=2)
axis(1, at=19, " ")
axis(1, at=20, "1994", las=2)
axis(1, at=21, " ")
axis(1, at=22, "1998", las=2)
axis(1, at=23, " ")
axis(1, at=24, "2002", las=2)
axis(1, at=25, " ")
axis(1, at=26, "2006", las=2)
axis(1, at=27, " ")
axis(1, at=28, "2010", las=2)
axis(1, at=29, " ")
axis(1, at=30, "2014", las=2)
axis(1, at=31, " ")
axis(1, at=32, "2018", las=2)

dev.off()


###################################################################
#Figure 8d - Q4 SE Plot
###################################################################

library(foreign)
library(extrafont)
library(readstata13)
loadfonts()
data<-read.dta13("Figure78_Q4dataset.dta")
scale<-data[,1]
smooth<-data[,2]
se<-data[,3]
lb<-data[,4]
ub<-data[,5]

pdf(file="Figure8d.pdf", family="Bookman")
plot(scale, se, type="l", xlim=c(2, 32), ylim=c(0, 75), xlab=substitute(paste('Year of Cycle ', italic('t'))), ylab="Standard Error", xaxt="n", main="Q4: Standard Errors")
box() 

axis(1, at=2, "1958", las=2)
axis(1, at=3, " ")
axis(1, at=4, "1962", las=2)
axis(1, at=5, " ")
axis(1, at=6, "1966", las=2)
axis(1, at=7, " ")
axis(1, at=8, "1970", las=2)
axis(1, at=9, " ")
axis(1, at=10, "1974", las=2)
axis(1, at=11, " ")
axis(1, at=12, "1978", las=2)
axis(1, at=13, " ")
axis(1, at=14, "1982", las=2)
axis(1, at=15, " ")
axis(1, at=16, "1986", las=2)
axis(1, at=17, " ")
axis(1, at=18, "1990", las=2)
axis(1, at=19, " ")
axis(1, at=20, "1994", las=2)
axis(1, at=21, " ")
axis(1, at=22, "1998", las=2)
axis(1, at=23, " ")
axis(1, at=24, "2002", las=2)
axis(1, at=25, " ")
axis(1, at=26, "2006", las=2)
axis(1, at=27, " ")
axis(1, at=28, "2010", las=2)
axis(1, at=29, " ")
axis(1, at=30, "2014", las=2)
axis(1, at=31, " ")
axis(1, at=32, "2018", las=2)

dev.off()